
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';

import '../../main.dart';
import '../view/home/page/device_scan_page.dart';

// 自定义滑动路由转换为 CustomTransitionPage
class SlideRightTransition extends CustomTransitionPage {
  SlideRightTransition({required super.child})
      : super(
    key:  ValueKey(child),
    transitionDuration: const Duration(milliseconds: 300),
    transitionsBuilder: (context, animation, secondaryAnimation, child) {
      print("SlideRightTransition${child}",);
      return FadeTransition(
        opacity:
        CurveTween(curve: Curves.easeInOutCirc).animate(animation),
        child: child,
      );
    },
  );
}
initRouter(){
  return GoRouter(
    initialLocation: '/',
    routes: [
      GoRoute(
        path: '/',
        builder: (context, state) =>const MyHomePage(),
        routes: [
          GoRoute(
            path: 'device/scan',
              pageBuilder:  (context, state) =>  SlideRightTransition(child: DeviceScanPage()),
          ),
        ],
      ),
    ],
  );
}
